<?php
/**
 * Created by PhpStorm.
 * User: Sky
 * Date: 16/1/25
 * Time: 下午5:50
 */

use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$web = Url::to("@web");
//获取微信js
$sign= WeixinUtils::getJs_SignPackage();
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>礼册兑换</title>
    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
    <link href="<?= $web ?>/css/home/global.css" rel="stylesheet" type="text/css">
    <link href="<?= $web ?>/css/home/voucher-exchange-user.css" rel="stylesheet" type="text/css">
    <script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script>
        $(function ($) {
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("html").css("font-size", w * 20 / 320);

        });

        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '<?=APPID?>', // 必填，公众号的唯一标识
            timestamp:<?=$sign['timestamp']?> , // 必填，生成签名的时间戳
            nonceStr: '<?=$sign['nonceStr']?>', // 必填，生成签名的随机串
            signature: '<?=$sign['signature']?>',// 必填，签名，见附录1
            jsApiList: ['scanQRCode'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });


        wx.ready(function(){

            $('#btn_scanQRCode').click(function(){
                wx.scanQRCode({
                    needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                    scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                    success: function (res) {
//                        var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
//                        $('#out_span').html(result);
                    }
                });

            });
        });


        href_voucher_exchange=function(){
            if($('#txt_code').val()==''){
                alert('编码不能为空');
                return;
            }
            if($('#txt_pwd').val()==''){
                alert('密码不能为空');
                return;
            }
            window.location.href = "<?=Url::to(["wx-home/voucher-exchange"]);?>?card_voucher="
                + $('#txt_code').val()+'&card_token='
                +$('#txt_pwd').val();

        };



    </script>
</head>
<body>
<div class="main">
    <div class="head">
        <div class="head-radius"><img src="<?= $web ?>/img/home/voucher-exchange-user/exchange-1.png"></div>
        <div class="head-words"><img src="<?= $web ?>/img/home/voucher-exchange-user/exchange-2.png"></div>
    </div>
    <div class="body">
        <div class="body-div body-div-number">编码：<input type="text" id="txt_code" placeholder="请输入编码"></div>
        <div class="body-div body-div-password">密码：<input type="password" id="txt_pwd" placeholder="请输入密码"></div>
    </div>
    <div class="btn" onclick="href_voucher_exchange();">
        确认兑换
    </div>
    <div class="code" id="btn_scanQRCode">
        <img src="<?= $web ?>/img/home/voucher-exchange-user/exchange-3.png">&nbsp;
        <span>扫码兑换</span>
    </div>
    <div class="foot">
        全国一站式礼赠服务&nbsp;&nbsp;&nbsp;400-860-3111&nbsp;&nbsp;
    </div>
</div>
<script>
    //console.log($(window).height())
    if($(".main").height() < $(window).height()){
        $(".main").height($(window).height())
    }
</script>
</body>
</html>